package xyz.jpcr.covid19app.Util;

import android.util.Log;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;

public class IDateUtil {
    private static IDateUtil iDateUtil = null;
    public static IDateUtil getInstance(){
        if(iDateUtil == null) {
            iDateUtil = new IDateUtil();
        }
        return iDateUtil;
    }

    public String formatDate(long date, int type) {
        String dateFormat = null;
        if (type == 0) {
            dateFormat = new SimpleDateFormat("dd MMM yyyy, hh:mm a", Locale.US).format(date);
            return dateFormat;
        } else if (type == 1) {
            dateFormat = new SimpleDateFormat("dd MMM yyyy", Locale.US).format(date);
            return dateFormat;
        } else if (type == 2) {
            dateFormat = new SimpleDateFormat("hh:mm a", Locale.US).format(date);
            return dateFormat;
        } else {
            Log.d("error", "Wrong input! Choose from 0 to 2");
            return "Error";
        }
    }

}
